package personal.zq.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.HashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * JVM信息查询与处理
 *
 * @author zhangqing
 * @version 1.0
 * @date 2022/6/17
 */
@Api(tags = "JVM信息查询与处理")
@RestController
@RequestMapping("/jvm")
public class JvmController {
    @ApiOperation("查询JVM基本信息")
    @PostMapping("/qryBase")
    public Map<String, Long> qry() {
        Map<String, Long> jvmMap = new HashMap<>();
        Runtime runtime = Runtime.getRuntime();
        jvmMap.put("最大内存(M)", runtime.maxMemory() / 1024 / 1024);
        jvmMap.put("总内存(M):", runtime.totalMemory() / 1024 / 1024);
        jvmMap.put("可用内存(M):", runtime.freeMemory() / 1024 / 1024);
        //        jvmMap.put("jvm可用的处理器核心的数量:", runtime.availableProcessors() * 1L);
        return jvmMap;
    }
}
